﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace dotsoftRAID_GUI
{
    public partial class DriveSelect : Form
    {
        public DriveSelect()
        {
            InitializeComponent();
        }

        private void DriveSelect_Load(object sender, EventArgs e)
        {
            string homeDrive = string.Format(@"{0}\", Environment.GetEnvironmentVariable("homedrive"));

            foreach (DriveInfo drive in DriveInfo.GetDrives())
            {
                if ((drive.IsReady && drive.RootDirectory.FullName != homeDrive) && drive.DriveType == DriveType.Fixed | drive.DriveType == DriveType.Removable)
                {
                    driveComboBox.Items.Add(drive.RootDirectory.FullName);
                }
            }
        }

        private void driveComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            deviceInfoListView.Items.Clear();

            DriveInfo drive = new DriveInfo(driveComboBox.SelectedItem.ToString());

            ListViewItem item = new ListViewItem(new string[]{
                drive.VolumeLabel,
                drive.DriveType.ToString(),
                drive.DriveFormat,
                Math.Round(((((double)Convert.ToDouble(drive.TotalSize) / 1024) / 1024) / 1024), 2) + " GB"
            });

            deviceInfoListView.Items.Add(item);
        }
    }
}
